package com.shensi.api.pay.client;

import com.alibaba.fastjson.JSONObject;
import com.shensi.api.pay.param.request.RechargeBalance;
import com.shensi.api.pay.pojo.CustomerCardUseRecord;
import com.shensi.api.pay.pojo.dto.CustomerCardChangeDto;
import com.shensi.api.pay.pojo.vo.ElectronicCardListVO;
import com.shensi.api.pay.pojo.vo.RechargePrivilegeVO;
import com.shensi.common.core.constant.CloudConstant;
import com.shensi.api.pay.param.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/*+
 * <Title> ElectronicMembershipCardController </Title>
 * <Description> 电子会员卡（储蓄卡）功能模块 </Description>
 * @Date 2021年3月22日
 */
//@QuJiaRequest()

@Api(tags = "电子会员卡（储蓄卡）功能")
@FeignClient(name = CloudConstant.PAY_SERVER)
public interface ElectronicMembershipCardClient {


    //查询该油站是否启用电子会员卡
    @RequestMapping(value = "/getStationCardEnabledFlag", method = RequestMethod.GET)
    @ResponseBody
    public String getStationCardEnabledFlag(Integer enterpriseId);

    //获取用户电子会员卡（储蓄卡）列表
    @RequestMapping(value = "/getElectronicCardList", method = RequestMethod.GET)
    @ApiOperation(value = "获取用户电子会员卡（储蓄卡）列表", httpMethod = "GET", notes = "获取用户电子会员卡（储蓄卡）列表")
    @Transactional
    public ResultData<ElectronicCardListVO> getElectronicCardList(@ApiParam(value = "油企ID", required = true) @RequestParam("enterpriseId") Integer enterpriseId,
                                                                  @ApiParam(value = "用户手机号", required = true) @RequestParam("mobilePhone") String mobilePhone);


    //用户充值电子会员卡（储蓄卡）生成充值记录
    @Transactional
    @PostMapping("/rechargeBalance")
    @ApiOperation(value = "用户充值电子会员卡（储蓄卡）生成充值记录")
    public String rechargeBalance(@RequestBody RechargeBalance rechargeBalance);


    //公众号充值拉起第三方支付
    @RequestMapping(value = "/rechargeToThirdPayment", method = RequestMethod.POST)
    @ApiOperation(value = "公众号充值拉起第三方支付", httpMethod = "POST", notes = "公众号充值拉起第三方支付")
    public String rechargeToThirdPayment(@RequestBody RechargeBalance rechargeBalance);


    @RequestMapping(value = "/getTLFusClassRechargePayCallback", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST)
    @Transactional
    public void getTLFusClassRechargePayCallback(@RequestParam("request")HttpServletRequest request, @RequestParam("response")HttpServletResponse response);


    // 金控接受异步异步通知
    @RequestMapping(value = "/JKCardNotice", consumes = "application/json", method = RequestMethod.POST)
    public void JKCardNotice(@RequestParam("request")HttpServletRequest request, @RequestParam("response")HttpServletResponse response);


    // 金控接受异步异步通知
    @RequestMapping(value = "/yunHuaCardNotice", consumes = "application/json", method = RequestMethod.POST)
    public void yunHuaCardNotice(@RequestParam("request")HttpServletRequest request, @RequestParam("response")HttpServletResponse response);

    @ApiOperation(value = "校验电子卡重复支付", httpMethod = "GET", notes = "校验电子卡重复支付")
    @RequestMapping(value = "/checkDzkRepeatPay", method = RequestMethod.GET)
    public String checkDzkRepeatPay(String ordNo);

    //电子卡支付
    @Transactional
    @RequestMapping(value = "/dzkPaySet", method = RequestMethod.GET)
    @ApiOperation(value = "电子卡支付", httpMethod = "GET", notes = "电子卡支付")
    public String dzkPaySet(@RequestParam("ordNo") String ordNo, @RequestParam("couponUserId") String couponUserId);

    /*
     * 公众号电子卡充值 通联异步回调通知
     * @param request
     * @return
     * @throws ParseException
     */
    @RequestMapping(value = "/getTLRechargePayCallback", consumes = "application/x-www-form-urlencoded", method = RequestMethod.POST)
    @Transactional
    public void getTLRechargePayCallback(@RequestParam("request")HttpServletRequest request, @RequestParam("response")HttpServletResponse response);


    //用户电子会员卡（储蓄卡）充值功能随行付回调功能
    @RequestMapping(value = "/getCardRechargeCallback", consumes = "application/json", method = RequestMethod.POST)
    @Transactional
    public JSONObject getCardRechargeCallback(@RequestBody JSONObject request);

    /***
     * 公众号 云闪付扫呗  用户电子会员卡（储蓄卡）充值功能支付回调
     * @param params
     * @return
     */
    @RequestMapping(value = "/getYunPayGzhCallback", consumes = "text/xml", method = RequestMethod.POST)
    @Transactional
    public net.sf.json.JSONObject getYunPayGzhCallback(@RequestBody String params);

    //获取用户电子会员卡（储蓄卡）充值消费记录
    @RequestMapping(value = "/getCardRecordList", method = RequestMethod.GET)
    @ApiOperation(value = "获取用户电子会员卡（储蓄卡）充值消费记录", httpMethod = "GET", notes = "获取用户电子会员卡（储蓄卡）充值消费记录")
    public String getCardRecordList(@ApiParam(value = "油企ID", required = true) @RequestParam("enterpriseId") Integer enterpriseId,
                                    @ApiParam(value = "用户mobilePhone", required = true) @RequestParam("mobilePhone") String mobilePhone, @RequestParam("usageType") String usageType,
                                    @RequestParam("pageSize") Integer pageSize,
                                    @RequestParam("pageNum") Integer pageNum, @RequestParam("cardOilsType") String cardOilsType);

    //查询油站电子会员卡（储蓄卡）充值设置规则
    @RequestMapping(value = "/getCardRechargeSettingList", method = RequestMethod.GET)
    @ApiOperation(value = "查询油站电子会员卡（储蓄卡）充值设置规则", httpMethod = "GET", notes = "查询油站电子会员卡（储蓄卡）充值设置规则")
    public String getCardRechargeSettingList(@ApiParam(value = "油企ID", required = true) @RequestParam("enterpriseId") Integer enterpriseId, @RequestParam("stationId") Integer stationId, @RequestParam("cardOilsType") String cardOilsType);

    //查询油站电子会员卡（储蓄卡）充值设置规则
    @RequestMapping(value = "/getCardRechargeMinAmt", method = RequestMethod.GET)
    @ApiOperation(value = "查询电子卡最低充值金额", httpMethod = "GET", notes = "查询油站电子会员卡（储蓄卡）充值设置规则")
    public String getCardRechargeMinAmt(@ApiParam(value = "油企ID", required = true) Integer enterpriseId);

    @PostMapping("/electronicCard/posUpdateBalance")
    @ApiOperation(value = "pos机更新会员电子卡余额")
    public ResultData<CustomerCardUseRecord> posUpdateBalance(@RequestBody @Validated(CustomerCardChangeDto.PosView.class) CustomerCardChangeDto cardChangeDto);

    @PostMapping("/electronicCard/pcUpdateBalance")
    @ApiOperation(value = "pc更新会员电子卡余额")
    public ResultData<CustomerCardUseRecord> pcUpdateBalance(@RequestBody @Validated(CustomerCardChangeDto.PcView.class) CustomerCardChangeDto cardChangeDto);

    @GetMapping("/electronicCard/getRechargePrivilegeList")
    @ApiOperation(value = "获取充值优惠信息")
    public ResultData<List<RechargePrivilegeVO>> getRechargePrivilegeList(@RequestParam("stationId") Long stationId,
                                                                          @RequestParam("cardType") String cardType);
}
